
import login from '@/views/login/index.vue'

import { createRouter, createWebHashHistory } from 'vue-router'
const paths = import.meta.glob('./modules/*.js', { eager: true })

const childRoutes = []
for (const key in paths) {
  if (Object.prototype.hasOwnProperty.call(paths, key)) {
    childRoutes.push(...paths[key].default)
  }
}

const routes = [
  {
    path: '/',
    redirect: '/login',
    name: 'Login',
    meta: { title: '登录', needToken: true }
  }, {
    path: '/login',
    name: 'login',
    component: login,
    meta: { title: '登录', needToken: true }
  },
  {
    path: '/:pathMatch(.*)*',
    name: '404',
    component: () => import('@/views/code/404/index.vue'),
    meta: { title: '404', needToken: true }
  },
  ...childRoutes
]

const $router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default $router

